gusucode.com > VC++ EMF图片浏览器(可读emf、wmf、emz、wmz、png……等)-源码程序 > VC++ EMF图片浏览器(可读emf、wmf、emz、wmz、png……等)-源码程序/code/Src/Client/scemflib/SCDCRendLines_i.cpp

    //Download by http://www.NewXing.com
/*
*	This file is part of the EMFexplorer projet.
*	Copyright (C) 2004 Smith Charles.
*
*	This library is free software; you can redistribute it and/or
*	modify it under the terms of the GNU Lesser General Public
*	License as published by the Free Software Foundation; either
*	version 2.1 of the License, or (at your option) any later version.
*
*   This library is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*   Lesser General Public License for more details.
*
*   You should have received a copy of the GNU Lesser General Public
*   License along with this library; if not, write to the Free Software
*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
*
*	Extension: for commercial use, apply the Equity Public License, which
*	adds to the normal terms of the GLPL a condition of donation to the author.
*   If you are interested in support for this source code,
*   contact Smith Charles <smith.charles@free.fr> for more information.
*/


#include "stdafx.h"
#include "SCEMFdcRenderer.h"

using namespace Gdiplus;

///////////////////////////////////////////////////////////////////////////////////////
// Lines and Curves management
//

///
///	Draw a set of lines, using current pen and brush in the spirit of GDI. 32-bit points.
///
void CSCEMFdcRenderer::SCDrawLines(POINT* pPoints, DWORD dwCount)
{
	T_SCDrawLines(pPoints, dwCount);
}

///
///	Draw a set of lines, using current pen and brush in the spirit of GDI. 16-bit points.
///
void CSCEMFdcRenderer::SCDrawLinesS(POINTS* pPoints, DWORD dwCount)
{
	T_SCDrawLines(pPoints, dwCount);
}

///
///	Draw a set of lines, using current pen and brush in the spirit of GDI. 32-bit points.
///
void CSCEMFdcRenderer::SCDrawLinesTo(POINT* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);
	Point* Pts = SCPointFromPOINTTo(m_PtCurPos, pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddLines(Pts, dwCount+1);
	else
	{
		//ASSERT(m_pPen);
		if (m_pPen)
			m_pGraphics->DrawLines(m_pPen, Pts, dwCount+1);
	}
	delete [] Pts;
	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}

///
///	Draw a set of lines, using current pen and brush in the spirit of GDI. 16-bit points.
///
void CSCEMFdcRenderer::SCDrawLinesToS(POINTS* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);
	Point* Pts = SCPointFromPOINTTo(m_PtCurPos, pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddLines(Pts, dwCount+1);
	else
	{
		ASSERT(m_pPen);
		m_pGraphics->DrawLines(m_pPen, Pts, dwCount+1);
	}
	delete [] Pts;
	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}


template <class T>
inline void CSCEMFdcRenderer::T_SCDrawLines(T* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);

	Point* Pts = SCPointFromPOINT(pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddLines(Pts, dwCount);
	else
	{
		//ASSERT(m_pPen);
		if (m_pPen)
			m_pGraphics->DrawLines(m_pPen, Pts, dwCount);
	}
	delete [] Pts;

	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}

///////////////////////////////////////////////////////////////////////////////////////
// Bezier
//

///
///	Draw Bezier curves, using current pen and brush in the spirit of GDI. 32-bit points.
///
void CSCEMFdcRenderer::SCDrawBezier(POINT* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);
	Point* Pts = SCPointFromPOINT(pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddBeziers(Pts, dwCount);
	else
	{
		ASSERT(m_pPen);
		m_pGraphics->DrawBeziers(m_pPen, Pts, dwCount);
	}
	delete [] Pts;
	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}

///
///	Draw Bezier curves, using current pen and brush in the spirit of GDI. 16-bit points.
///
void CSCEMFdcRenderer::SCDrawBezierS(POINTS* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);
	Point* Pts = SCPointFromPOINT(pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddBeziers(Pts, dwCount);
	else
	{
		ASSERT(m_pPen);
		m_pGraphics->DrawBeziers(m_pPen, Pts, dwCount);
	}
	delete [] Pts;
	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}

///
///	Draw Bezier curves, using current point in DC as the first point,
/// pen and brush in the spirit of GDI. 32-bit points.
///
void CSCEMFdcRenderer::SCDrawBezierTo(POINT* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);
	Point* Pts = SCPointFromPOINTTo(m_PtCurPos, pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddBeziers(Pts, dwCount+1);
	else
	{
		ASSERT(m_pPen);
		m_pGraphics->DrawBeziers(m_pPen, Pts, dwCount+1);
	}
	delete [] Pts;
	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}

///
///	Draw Bezier curves, using current point in DC as the first point,
/// pen and brush in the spirit of GDI. 16-bit points.
///
void CSCEMFdcRenderer::SCDrawBezierToS(POINTS* pPoints, DWORD dwCount)
{
	ASSERT(m_pGraphics);
	Point* Pts = SCPointFromPOINTTo(m_PtCurPos, pPoints, dwCount);
	if (m_pPath)
		m_pPath->AddBeziers(Pts, dwCount+1);
	else
	{
		ASSERT(m_pPen);
		m_pGraphics->DrawBeziers(m_pPen, Pts, dwCount+1);
	}
	delete [] Pts;
	// update current position
	SCUpdateCurPos(pPoints[dwCount-1].x, pPoints[dwCount-1].y);
}